package ezonsport.android.ui.systemManage;

import ezonsport.android.core.systemManage.User;
import ezonsport.android.data.DataHelper;
import ezonsport.android.service.SystemManageService;

/**
 * 
 * @author 桑成龙 2012.6.27
 *
 */
public class UserInfoManageController {

	private SystemManageService systemManageService;
	private UserInfoManageModel userInfoManageModel;
	/**
	 * 构造函数
	 * @param dataHelper：DataHelper对象
	 */
	public UserInfoManageController(DataHelper dataHelper){
		systemManageService = new SystemManageService(dataHelper);
		userInfoManageModel = new UserInfoManageModel();
	}
	
	/**
	 * 获取用户信息，返回user对象，与getUserInfoModel一样
	 * @param userName：用户名
	 * @return：User
	 */
	public User getUserInfo(String userName){
		
		return systemManageService.getUserInfo(userName);
		
	}
	/**
	 * 获取用户信息：返回UserInfoManageModel对象，与getUserInfo一样，
	 * @param userName：用户名
	 * @return：UserInfoManageModel
	 */
	public UserInfoManageModel getUserInfoModel(String userName){
		User user = getUserInfo(userName);
		userInfoManageModel.setEmail(user.getEmail());
		userInfoManageModel.setNickName(user.getNickName());
		userInfoManageModel.setGender(user.getGender());
		userInfoManageModel.setBirthDate(user.getBirthDate());
		userInfoManageModel.setHeight(user.getHeight());
		userInfoManageModel.setWeight(user.getWeight());
		//userInfoManageModel.setAge(user.getAge());
		
		return userInfoManageModel;
	}
	
	/**
	 * 设置用户信息
	 * @param model：UserInfoManageModel
	 */
	public void setUserInfo(UserInfoManageModel model){
		User user = new User();
		
		user.setEmail(model.getEmail());
		user.setNickName(model.getNickName());
		//user.setAge(model.getAge());
		user.setBirthDate(model.getBirthDate());
		user.setGender(model.getGender());
		user.setHeight(model.getHeight());
		user.setWeight(model.getWeight());
		systemManageService.setUserInfo(user);
	}
}
